﻿using System;
using System.Collections.Generic;
using System.Text;
using BBMS.DLL.Base;

namespace BBMS.DLL.DataContract
{
    public class QuayNganhHang : BBMS.DLL.Base.ObjectBase
    {
        public string MaQuay;
        public string MaHang;        
        public string TenQuay;
        public string Ten;

        public QuayNganhHang()
        {
        }

        public QuayNganhHang(string maquay, string mahang,  string tenquay, string ten)
        {
            this.MaQuay = maquay;
            this.MaHang = mahang;
            this.TenQuay = tenquay;
            this.Ten = ten;
        }

        public override object Key
        {
            get
            {
                return new KeyValuePair(this.MaQuay,this.MaHang);
            }
        }
        //public override string Name
        //{
        //    get
        //    {
        //        return new KeyValuePair(this.TenQuay, this.Ten);
        //    }
        //}
        public override string TableName
        {
            get
            {
                return "nganhhang_quay";
            }
        }
        
        public override string[] KeyFields
        {
            get
            {
                return new string[2] { "MaQuay", "MaHang" };
            }
        }

        public override System.Data.DataTable GetObjectDataTable()
        {
            System.Data.DataTable dt = new System.Data.DataTable("nganhhang_quay");
            dt.Columns.Add("MaQuay", typeof(String));
            dt.Columns.Add("MaHang", typeof(String));
            dt.Columns.Add("TenQuay", typeof(String));
            dt.Columns.Add("Ten", typeof(String));
            return dt;
        }
        public override System.Data.DataRow ObjectToDataRow()
        {
            System.Data.DataRow row = this.GetObjectDataTable().NewRow();
            row["MaQuay"] = this.MaQuay;
            row["MaHang"] = this.MaHang;
            row["TenQuay"] = this.TenQuay;
            row["Ten"] = this.Ten;
            return row;
        }

        public override BBMS.DLL.Base.ObjectBase DataRowToObject(System.Data.DataRow row)
        {
            QuayNganhHang obj = null;
            try
            {
                obj = new QuayNganhHang(row["MaQuay"].ToString(), row["MaHang"].ToString(), row["TenQuay"].ToString(), row["Ten"].ToString());
            }
            catch { }
            return obj;
        }

        public override BBMS.DLL.Base.ObjectBase DataReaderToObject(MySql.Data.MySqlClient.MySqlDataReader rd)
        {
            QuayNganhHang obj = null;
            try
            {
                obj = new QuayNganhHang(rd["MaQuay"].ToString(), rd["MaHang"].ToString(),
                    rd["TenQuay"].ToString(), rd["Ten"].ToString());
            }
            catch { }
            return obj;
        }

    }
}
